Skip to content

feat(parser): resolve repository-local Python star imports#638

Merged
tirth8205 merged 1 commit into
mainfrom
codex/port-wildcard-imports
Jul 17, 2026
Merged

feat(parser): resolve repository-local Python star imports#638
tirth8205 merged 1 commit into
mainfrom
codex/port-wildcard-imports

Conversation

@tirth8205

Copy link
Copy Markdown
Owner

Summary

  • port the viable wildcard-import behavior from closed PR feat(parser): expand Python from X import * in import_map #328 (source commit 7717968) onto current main, without carrying the stale stacked branch
  • resolve direct, relative, transitive, explicit __all__, and notebook Python star imports to repository-local symbols
  • keep import discovery inside the configured repository, including rejecting symlink escapes before reading a target
  • share a bounded, fingerprinted, thread-safe cache across parser instances and fail soft when an imported module cannot be read or parsed

The implementation commit preserves Gideon Zenz's authorship with a Co-authored-by trailer.

Safety and compatibility

  • implicit exports include public functions/classes only
  • __all__ is accepted only when it is a literal list/tuple of strings
  • recursive imports use cycle protection
  • external paths and symlink escapes are not read
  • cached entries are keyed by resolved path, mtime, and size and are bounded to 15,000 entries

Tests

Added red/green regressions covering:

  • direct public/private wildcard imports
  • literal __all__
  • transitive relative wildcard imports
  • repository-boundary and symlink-escape rejection
  • cache reuse across worker parser instances
  • concurrent parser instances computing an import once
  • imported-module parser failures
  • notebook wildcard imports

Verification on the final rebase:

  • pytest -q: 1515 passed, 1 skipped, 2 xpassed
  • focused parser/notebook suite: 158 passed, 2 xpassed
  • ruff check code_review_graph/: passed
  • ruff check code_review_graph/parser.py tests/test_python_star_imports.py: passed
  • mypy code_review_graph/ --ignore-missing-imports --no-strict-optional: passed
  • code-review graph: 2 changed files analyzed; full suite run because the central parser has a broad impact radius

Source: #328

Port the viable behavior from PR #328 (commit 7717968) onto the current parser. Expand direct, __all__, relative, transitive, and notebook imports without reading outside the configured repository; share a bounded, fingerprinted, thread-safe cache across worker parser instances and fail soft on imported-module errors.

Co-authored-by: Gideon Zenz <91069374+gzenz@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.65 (MEDIUM) — 27 changed function(s)/class(es), 0 affected flow(s), 19 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.65 medium code_review_graph/parser.py::CodeParser._parse_notebook_cells code_review_graph/parser.py:1478 no
0.65 medium code_review_graph/parser.py::CodeParser._expand_python_star_imports code_review_graph/parser.py:5834 no
0.65 medium code_review_graph/parser.py::CodeParser._python_repo_boundary code_review_graph/parser.py:5968 no
0.65 medium code_review_graph/parser.py::CodeParser._path_is_within code_review_graph/parser.py:5979 no
0.65 medium code_review_graph/parser.py::CodeParser._resolve_python_module_in_repo code_review_graph/parser.py:5987 no
0.65 medium code_review_graph/parser.py::CodeParser._resolve_imported_symbol code_review_graph/parser.py:6344 no
0.60 medium code_review_graph/parser.py::CodeParser.parse_bytes code_review_graph/parser.py:1039 no
0.60 medium code_review_graph/parser.py::CodeParser._get_python_star_exports code_review_graph/parser.py:5859 no
0.60 medium code_review_graph/parser.py::CodeParser._read_python_star_exports code_review_graph/parser.py:5896 no
0.60 medium code_review_graph/parser.py::CodeParser._extract_python_dunder_all code_review_graph/parser.py:5948 no

Test gaps

  • code_review_graph/parser.py::CodeParser (code_review_graph/parser.py:890)
  • code_review_graph/parser.py::CodeParser.__init__ (code_review_graph/parser.py:895)
  • code_review_graph/parser.py::CodeParser.parse_bytes (code_review_graph/parser.py:1039)
  • code_review_graph/parser.py::CodeParser._parse_notebook_cells (code_review_graph/parser.py:1478)
  • code_review_graph/parser.py::CodeParser._expand_python_star_imports (code_review_graph/parser.py:5834)
  • ...and 14 more without direct tests

Token savings: this graph-backed report used ~77,613 fewer tokens (~94%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205
tirth8205 merged commit 8c227dd into main Jul 17, 2026
11 checks passed
@tirth8205
tirth8205 deleted the codex/port-wildcard-imports branch July 17, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant